home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4779 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: s20.phxslip4.indirect.com!pronet01
  2. From: pronet01@indirect.com (Mark Miller)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What does the -O option do???!!!
  5. Date: Mon, 5 Feb 1996 19:31:15 UNDEFINED
  6. Organization: Promark One
  7. Message-ID: <pronet01.34.003B9BB5@indirect.com>
  8. References: <4ehger$cj9@mark.ucdavis.edu> <4emlsq$odt@airdmhor.gen.nz>
  9. NNTP-Posting-Host: s20.phxslip4.indirect.com
  10. X-Newsreader: Trumpet for Windows [Version 1.0 Rev B final beta #1]
  11.  
  12. In article <4emlsq$odt@airdmhor.gen.nz> gumboot@airdmhor.gen.nz (Simon Hosie) writes:
  13. >From: gumboot@airdmhor.gen.nz (Simon Hosie)
  14. >Subject: Re: What does the -O option do???!!!
  15. >Date: 31 Jan 1996 15:58:34 +1300
  16.  
  17. >Ricardo E Espinoza-Ibarra:
  18.  
  19. >> Does anyone know what the -O option in gcc C compiler does?  I have tried
  20. >> to compile a program in two different ways: 1) cc -o first first.c, and it
  21. >> worksfine; 2) cc -o first first.c -O, and it runs faster than the other one. 
  22. >> I checked to see if it had changed the program code in anyway, and it
  23. >> hadn't. This option stands for "optimizer", but I want to know how the heck
  24. >> it optimizes the program!  
  25.  
  26. >  Perhaps if the second time you ran it you used "cc -o second first.c -O"
  27. >and then "cmp first second" rather than using "cc -o first fisrt.c -O" and
  28. >then "cmp first first"
  29.  
  30. It definitely is the optimizing compiler flag...
  31.  
  32. Warning: if you DO use the "-O" make sure you know of the caveats
  33. with certain compilers...  Older versions of gcc/g++ did "evil" things
  34. to code compiled with "-O"...  The compiler attempts to do double 
  35. checks and reorganization of object code...
  36.  
  37. Hint:  When you're done using a pointer (and it has not gone out of
  38. scope), explicitly set it to NULL..  I have seen the optimized version
  39. move addresses for a pointer variable that you have used "free" on..
  40.  
  41.  
  42.